﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CommandMenuBinding.cs" company="">
//   
// </copyright>
// <summary>
//   The command menu binding.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Bindings
{
    using Libium.UseCases;
    using Libium.Views;

    /// <summary>
    ///   The command menu binding.
    /// </summary>
    public class CommandMenuBinding : BindableViewBinding<ICommandMenu, ICommandMenuView>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CommandMenuBinding"/> class.
        /// </summary>
        /// <param name="service">
        /// The service. 
        /// </param>
        /// <param name="menu">
        /// The menu. 
        /// </param>
        /// <param name="view">
        /// The view. 
        /// </param>
        public CommandMenuBinding(IBindService service, ICommandMenu menu, ICommandMenuView view)
            : base(service, menu, view)
        {
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///   The bind.
        /// </summary>
        public override void Bind()
        {
            base.Bind();
            View.Text = UseCase.Text;
            View.Tooltip = UseCase.Description;
            foreach (var command in UseCase.Commands)
            {
                var commandView = View.AddCommandView();
                Bind(command, commandView);
            }
        }

        #endregion
    }
}